<?php
	include_once dirname(dirname(dirname(__FILE__))).'/inc/bootConfig.php';
	include_once '../checkLogin.php';
	include_once '../Public/login/checkUserGrade.php';
	
	userLimit($username,1);
	$id = getRequest('id');
	if(empty($id)){
		jstop('参数错误');
	}
	$userinfo = User_User::getAdminListById($id);
	
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
<!--
body {
	margin-left: 3px;
	margin-top: 0px;
	margin-right: 3px;
	margin-bottom: 0px;
}
.STYLE1 {
	color: #e1e2e3;
	font-size: 12px;
}
.STYLE6 {color: #000000; font-size: 12; }
.STYLE10 {color: #000000; font-size: 12px; }
.STYLE19 {
	color: #344b50;
	font-size: 12px;
}
.STYLE21 {
	font-size: 12px;
	color: #3b6375;
}
.STYLE22 {
	font-size: 12px;
	color: #295568;
}
-->
</style>
</head>

<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="24" bgcolor="#353c44">
        <?php 
    		include_once 'inc/userinfotop.html';
    	?></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>
    	<form action="" method="post" id="form1" onsubmit="return checkinfo();"> 
    	<table width="100%" align="center" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce">
	   	  <tr>
	        <td height="20"  bgcolor="d3eaef" class="STYLE6"  colspan='2' align="center"><h3>后台管理员数据编辑</h3></td>
	      </tr>
	      <tr>
	        <td width="40%" height="20" bgcolor="#FFFFFF" class="STYLE6"><div align="right"><span class="STYLE10">用户登录名：</span></div></td>
	        <td width="60%" height="20" bgcolor="#FFFFFF" class="STYLE6">
				<input type="text" <?php if($userinfo['z_username']==$username) echo ' readonly ';?> value="<?php echo isset($userinfo['z_username'])?$userinfo['z_username']:''?>" name="username" size="16" id="usname"/>
				<input type="hidden" value="<?php echo isset($userinfo['z_id'])?$userinfo['z_id']:''?>" name="userid"/>
			</td>
	      </tr>
	      <tr>
	        <td width="40%" height="20" bgcolor="#FFFFFF" class="STYLE6"><div align="right"><span class="STYLE10">用户真实姓名：</span></div></td>
	        <td width="60%" height="20" bgcolor="#FFFFFF" class="STYLE6">
				<input type="text" value="<?php echo isset($userinfo['z_realname'])?$userinfo['z_realname']:''?>" name="realname" size="16"/>
			</td>
	      </tr>
	      <tr>
	        <td width="40%" height="20" bgcolor="#FFFFFF" class="STYLE6"><div align="right"><span class="STYLE10">用户管理组：</span></div></td>
	        <td width="60%" height="20" bgcolor="#FFFFFF" class="STYLE6">
				<select name="usergrade" id="usgrade">
	        		<option value='0' <?php if($userinfo['z_userGrade']==0)echo 'selected'?>>超级管理员</option>
	        		<option value='1' <?php if($userinfo['z_userGrade']==1)echo 'selected'?>>管理员</option>
	        		<option value='2' <?php if($userinfo['z_userGrade']==2)echo 'selected'?>>会员</option>
	        	</select>
			</td>
	      </tr>
	      <tr>
	        <td width="40%" height="20" bgcolor="#FFFFFF" class="STYLE6"><div align="right"><span class="STYLE10">用户手机号：</span></div></td>
	        <td width="60%" height="20" bgcolor="#FFFFFF" class="STYLE6">
				<input type="text" value="<?php echo isset($userinfo['z_phone'])?$userinfo['z_phone']:''?>" name="userphone" size="16"/>
			</td>
	      </tr>
	      <tr>
	        <td width="40%" height="20" bgcolor="#FFFFFF" class="STYLE6"><div align="right"><span class="STYLE10">最后一次登录IP：</span></div></td>
	        <td width="60%" height="20" bgcolor="#FFFFFF" class="STYLE6">
				<input type="text" readonly value="<?php echo isset($userinfo['z_ip'])?$userinfo['z_ip']:''?>" name="lastip" size="16"/>
			</td>
	      </tr>
	      <tr>
	        <td width="40%" height="20" bgcolor="#FFFFFF" class="STYLE6"><div align="right"><span class="STYLE10">用户最后登录时间：</span></div></td>
	        <td width="60%" height="20" bgcolor="#FFFFFF" class="STYLE6">
				<input type="text" readonly value="<?php echo isset($userinfo['z_lasttime'])?$userinfo['z_lasttime']:''?>" name="lasttime" size="26" id="usname"/>
			</td>
	      </tr>
	      <tr>
	        <td width="40%" height="20" bgcolor="#FFFFFF" class="STYLE6"><div align="right"><span class="STYLE10"></span></div></td>
	        <td width="60%" height="20" bgcolor="#FFFFFF" class="STYLE6">
				<input type="submit" value="提交" name="submit" id="submit_s"/>
				<input type="reset" value="重置" name="reset" id="reset_s"/>
				<input type="button" value="修改密码" name="editpwd" id="reset_s" onclick="location.href='editpwd.php?id=<?php echo $id;?>'"/>
				<input type="button" value="返回" name="reset" id="reset_s" onclick="location.href='userList.php'"/>
			</td>
	      </tr>
      </table>
      </form>
    </td>
  </tr>
</table>
</body>
</html>
<script type="text/javascript">
<!--
function checkinfo(){
	var form = document.getElementById('form1');
	if(form.username.value.length<1){
		alert('请输入用户名');
		form.username.focus;
		return false;
	}
	if(form.realname.value.length<1){
		alert('请输入用户真实姓名');
		form.realname.focus;
		return false;
	}
	if(form.userphone.value.length<1){
		alert('请输入用户手机号');
		form.userphone.focus;
		return false;
	}
	if(!checkphone(form.userphone.value)){
		alert('请输入正确的手机号码');
		return false;
	}
	if(!confirm('确认修改吗？')){
		return false;
	}
}
function checkphone(phone){
	var reg =/^0{0,1}(13[0-9]|15[0-9]|18[0-9])[0-9]{8}$/;
	
	if(reg.test(phone)){
		return true;
	}
	return false; 
}
//-->
</script>
<?php 
	if(isset($_POST['submit'])&&$_POST['submit']&&!empty($_POST['username'])){
		if(User_User::updateAdminInfo($_POST)){
			jstop('用户信息修改成功');
		}else{
			jstop('数据异常，请重试！');
		}
	}
?>
	